package com.work.db;

import javax.servlet.*;

import com.work.util.Log;

public class HibernateListener implements ServletContextListener {
	 
	@Override
    public void contextInitialized(ServletContextEvent event) {
		Log.info(HibernateListener.class, "Context INITIALIZED!!!");
        HibernateUtil.getSessionFactory(); // Just call the static initializer of that class    
    }
 
	@Override
    public void contextDestroyed(ServletContextEvent event) {
		Log.info(HibernateListener.class, "Context DESTROYED!!!");
        HibernateUtil.getSessionFactory().close(); // Free all resources
    }

}
